<html>
<head><meta charset="utf-8"><title>Symbol names with intel syntax · project-inline-asm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/index.html">project-inline-asm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Symbol.20names.20with.20intel.20syntax.html">Symbol names with intel syntax</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="189399159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Symbol%20names%20with%20intel%20syntax/near/189399159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Symbol.20names.20with.20intel.20syntax.html#189399159">(Feb 29 2020 at 18:05)</a>:</h4>
<p>I've just come across a pretty significant issue with Intel syntax: some symbol names can't be represented.</p>



<a name="189399166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Symbol%20names%20with%20intel%20syntax/near/189399166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Symbol.20names.20with.20intel.20syntax.html#189399166">(Feb 29 2020 at 18:06)</a>:</h4>
<p>For example <code>eax</code>, <code>byte</code>, etc.</p>



<a name="189399216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Symbol%20names%20with%20intel%20syntax/near/189399216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Symbol.20names.20with.20intel.20syntax.html#189399216">(Feb 29 2020 at 18:06)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="nf">mov</span> <span class="no">eax</span><span class="p">,</span> <span class="no">eax</span> <span class="c"># is this a symbol or a register</span>
</pre></div>



<a name="189399231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Symbol%20names%20with%20intel%20syntax/near/189399231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Symbol.20names.20with.20intel.20syntax.html#189399231">(Feb 29 2020 at 18:06)</a>:</h4>
<p>There doesn't appear to be a solution <a href="https://sourceware.org/bugzilla/show_bug.cgi?id=37" target="_blank" title="https://sourceware.org/bugzilla/show_bug.cgi?id=37">https://sourceware.org/bugzilla/show_bug.cgi?id=37</a></p>



<a name="189399391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Symbol%20names%20with%20intel%20syntax/near/189399391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Symbol.20names.20with.20intel.20syntax.html#189399391">(Feb 29 2020 at 18:11)</a>:</h4>
<p>LLVM's internal assembler seems to be able to parse quoted strings as symbols: <code>"eax"</code></p>



<a name="189399406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Symbol%20names%20with%20intel%20syntax/near/189399406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Symbol.20names.20with.20intel.20syntax.html#189399406">(Feb 29 2020 at 18:11)</a>:</h4>
<p>But that doesn't work in GAS: <code>"eax"</code> is still parsed as a register name</p>



<a name="189399827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Symbol%20names%20with%20intel%20syntax/near/189399827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Symbol.20names.20with.20intel.20syntax.html#189399827">(Feb 29 2020 at 18:22)</a>:</h4>
<p>I don't really see how that's significant for Rust inline asm, can you elaborate? One would have to deliberately give a symbol one of these names with <code>#[no_mangle]</code> (and use it with intel-style asm) to run into this, and platform-/toolchain-dependent breakage when giving symbols certain "reserved" names is nothing new or specific to inline asm. It also isn't novel that assemblers have all sorts of weird corner cases that vary between implementations or versions.</p>



<a name="189399839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Symbol%20names%20with%20intel%20syntax/near/189399839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Symbol.20names.20with.20intel.20syntax.html#189399839">(Feb 29 2020 at 18:23)</a>:</h4>
<p>It is significant because we provide a <code>sym</code> operand type which will insert the symbol of a given <code>static</code> or <code>fn</code> into the asm code.</p>



<a name="189399849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Symbol%20names%20with%20intel%20syntax/near/189399849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Symbol.20names.20with.20intel.20syntax.html#189399849">(Feb 29 2020 at 18:24)</a>:</h4>
<p>You would expect this to work correctly for all symbol names.</p>



<a name="189399906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Symbol%20names%20with%20intel%20syntax/near/189399906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Symbol.20names.20with.20intel.20syntax.html#189399906">(Feb 29 2020 at 18:25)</a>:</h4>
<p>I realize that, but as I said you'd have to deliberately pick such a name with <code>#[no_mangle]</code> and when you do that, there's a million things other than inline asm that can break depending on the name.</p>



<a name="189399956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216763-project-inline-asm/topic/Symbol%20names%20with%20intel%20syntax/near/189399956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/216763-project-inline-asm/topic/Symbol.20names.20with.20intel.20syntax.html#189399956">(Feb 29 2020 at 18:26)</a>:</h4>
<p>Eh, fair enough.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>